package com.orhon.smartcampus.modules.baseinfo.entity;

import com.orhon.smartcampus.modules.base.entity.Schools;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where;

import java.util.Date;
import java.sql.Timestamp;

@Setter
@Getter
@EqualsAndHashCode
@Entity
@Table(name = "baseinfo_semester", schema = "smartcloud", catalog = "")
public class Semester {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    private Long id;
    @Column(name = "semester_name", nullable = true)
    private String semesterName;
    @Column(name = "yearly_code", nullable = true, length = 32)
    private String yearlyCode;
    @Column(name = "semester_code", nullable = true, length = 50)
    private String semesterCode;
    @Column(name = "is_current", nullable = true)
    private Integer isCurrent;
    @Column(name = "start_at", nullable = true)
    private Date startAt;
    @Column(name = "end_at", nullable = true)
    private Date endAt;
    @Column(name = "week_total", nullable = true)
    private Integer weekTotal;
    @Column(name = "semester_number", nullable = true)
    private Integer semesterNumber;
    @Column(name = "teaching_start_at", nullable = true)
    private Date teachingStartAt;
    @Column(name = "teaching_end_at", nullable = true)
    private Date teachingEndAt;
    @Column(name = "semester_status", nullable = true)
    private Integer semesterStatus;
    @Column(name = "first_week_monday", nullable = true)
    private Date firstWeekMonday;
    @Column(name = "first_week_sunday", nullable = true)
    private Date firstWeekSunday;
    @Column(name = "mark", nullable = true, length = 255)
    private String mark;
    @Column(name = "created_at", nullable = true)
    private Date createdAt;
    @Column(name = "created_by", nullable = true)
    private Integer createdBy;
    @Column(name = "updated_at", nullable = true)
    private Date updatedAt;
    @Column(name = "updated_by", nullable = true)
    private Integer updatedBy;
    @Column(name = "deleted_at", nullable = true)
    private Date deletedAt;

    @ManyToOne(fetch = FetchType.LAZY)
    @Where(clause = "ISNULL(deleted_at)")
    @JoinColumn(name = "school_id", referencedColumnName = "id")
    @NotFound(action=NotFoundAction.IGNORE)
    private Schools baseSchoolsBySchoolId;


}
